/*
 * @Author: zhuxiaoyi
 * @Date: 2021-10-28 12:40:36
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2024-04-03 11:37:06
 * @Description:
 */
import service from "@/utils/request";

const geoserverBaseURL = "/geoserver/rest";
const backEndBaseURL = "/algorithmApi";

// const BASE_URL = "/zyjy-knowleges-api";
export default {
  login: {
    loginSystemURL: "/oauth/token",
    loginSystem: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.postQuery(
        this.loginSystemURL,
        params,
        successCallBack,
        errorCallBack
      );
    },
  },
  sldManage: {
    getStylesURL: "/workspaces/result/styles",
    getStyles: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.get(
        geoserverBaseURL + this.getStylesURL,
        params,
        successCallBack,
        errorCallBack
      );
    },
    getSldURL: "/workspaces/result/styles",
    getSld: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.get(
        geoserverBaseURL + this.getSldURL + "/" + params.name + ".sld",
        params,
        successCallBack,
        errorCallBack
      );
    },
    deleteSldURL: "/workspaces/result/styles",
    deleteSld: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.deleteQuery(
        geoserverBaseURL + this.getSldURL + "/" + params.name,
        params,
        successCallBack,
        errorCallBack
      );
    },
  },
  algorithmManage: {
    AlgorithmsURL: "/algorithm",
    getAlgorithms: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.get(
        backEndBaseURL + this.AlgorithmsURL,
        params,
        successCallBack,
        errorCallBack
      );
    },
    deleteAlgorithm: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.deleteJson(
        backEndBaseURL + this.AlgorithmsURL + `/${params.id}`,
        params,
        successCallBack,
        errorCallBack
      );
    },
    updateAlgorithm: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.putJson(
        backEndBaseURL + this.AlgorithmsURL + `/${params.id}`,
        params,
        successCallBack,
        errorCallBack
      );
    },
    executeAlgorithm: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.get(
        backEndBaseURL + this.AlgorithmsURL + `/${params.id}`,
        params,
        successCallBack,
        errorCallBack
      );
    }
  },
  taskManage: {
    taskURL: "/task",
    getTasks: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.get(
        backEndBaseURL + this.taskURL,
        params,
        successCallBack,
        errorCallBack
      );
    },
    deleteTask: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.deleteJson(
        backEndBaseURL + this.taskURL + `/${params.id}`,
        params,
        successCallBack,
        errorCallBack
      );
    },
    getTreeTasksURL: "/task/tree",
    getTreeTasks: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.get(
        backEndBaseURL + this.getTreeTasksURL,
        params,
        successCallBack,
        errorCallBack
      );
    },
    updateTaskStatusURL:"/task/changeStatus",
    updateTaskStatus: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.putJson(
        backEndBaseURL + this.updateTaskStatusURL + `/${params.id}`,
        params,
        successCallBack,
        errorCallBack
      );
    },
    publishResultURL:"/task/publish",
    publishResult: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.get(
        backEndBaseURL + this.publishResultURL + `/${params.id}`,
        params,
        successCallBack,
        errorCallBack
      );
    },
    pushResultURL:"/task/pushResult",
    pushResult: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.putJson(
        backEndBaseURL + this.pushResultURL + `/${params.id}`,
        params,
        successCallBack,
        errorCallBack
      );
    },
    statusListenURL:"/task/statusListen",
    statusListen: function (
      params: any,
      successCallBack: Function,
      errorCallBack: Function
    ) {
      service.putJson(
        backEndBaseURL + this.statusListenURL,
        params,
        successCallBack,
        errorCallBack
      );
    },
  },
};
